<?php

class Login extends Controller {

	function index()
	{
    if ($this->session->userdata('is_logged') != 1)
		  $this->load->view('login_form');
		else
		  $this->load->view('home');
	}
  
  function do_login()
  {
    $username = $this->input->post('username');
    $password = $this->input->post('password');
		$this->load->model('Utenti_model');
		
		if ($this->Utenti_model->autentica($username, md5($password)))
		{
			$datiSessione = array(
				'username' => $username,
				'is_logged' => TRUE
			);
			$this->session->set_userdata($datiSessione);
			$this->load->view('home');
		}
		else
			$this->load->view('login_form');
  }
  
}